package state;

import particle.core.platform.Platform;
import particle.core.tools.Size;
import particle.core.view.View;
import particle.core.view.controls.Container;
import state.bean.GameRect;
import state.util.Hashtable;

public class GameGlobal {
  public static int TIME_OUT = 0;

  public static void init(Midlet miDlet, View view1, Container container1) {
    // Xác định kích cỡ màn hình hiện tại là màn hình ngang hay màn hình dọc
    systemCanvas = new SystemCanvas(view1, container1);
    systemCanvas.setMidlet(miDlet);
    Platform platform = Platform.getInstance();
    Size screenSize = platform.getScreenResolution();
    if (screenSize.width >= 320) {
      GameConstants.IS_240x320_SCREEN = false;
      GameConstants.SCREEN_WIDTH = screenSize.width;
      GameConstants.SCREEN_HEIGHT = screenSize.height;
    } else {
      GameConstants.IS_240x320_SCREEN = true;
      GameConstants.SCREEN_WIDTH = screenSize.width;
      GameConstants.SCREEN_HEIGHT = screenSize.height;
    }
    GameConstants.DEVICE_SCREEN = new GameRect(0, 0, GameConstants.SCREEN_WIDTH, GameConstants.SCREEN_HEIGHT);

    // Load resource for default category
    resourceCategory = new Hashtable();
    Hashtable defaultResourceMaster = ResourceRms.loadMasterRecord(GameConstants.DEFAULT_RESOURCE_CATEGORY);
    if (defaultResourceMaster != null) {
      resourceCategory.put(GameConstants.DEFAULT_RESOURCE_CATEGORY, defaultResourceMaster);
    }
  }

  public static SystemCanvas systemCanvas = null;
  public static GameAlert alert = null;

  // Các biến để download resource
  public static int totalDownloadResource = Integer.MAX_VALUE;
  public static int downloadedCount = 0;

  public static Hashtable resourceCategory = null;

  public static void nextState(GameForm state, Hashtable table) {
    systemCanvas.nextState(state, table);
  }

  public static void nextState1(GameForm state, Hashtable table, int transformType) {
    systemCanvas.nextState1(state, table, transformType);
  }

  public static Midlet getMidlet() {
    return systemCanvas.getMidlet();
  }

  public static void setMidlet(Midlet midlet) {
    systemCanvas.setMidlet(midlet);
  }

  public static void setTimerDelay(int delay) {
    systemCanvas.setTimerDelay(delay);
  }
}
